import { getMyreadlist } from '@/services/flowMine/waitApprovals';

export default {
    namespace: 'myreading',
    state: {
        myreadingList: [],
        myreadingPagination: {
            current: 1,
            pageSize: 10,
            total: 0
        },
        order: '',
        applytype: []
    },
    effects: {
        *fetchMyreadingList({ payload }, { call, put }) {
            const result = yield call(getMyreadlist, payload);
            if (result && result.code === 10000) {
                yield put({
                    type: 'save',
                    payload: {
                        // order: payload.orderBy,
                        myreadingList: result.data.rows,
                        myreadingPagination: {
                            pageSize: result.data.pageSize,
                            current: result.data.pageNo,
                            total: result.data.total
                        }
                    }
                });
            }
        }
    },
    reducers: {
        save(state, { payload }) {
            return {
                ...state,
                ...payload
            };
        }
    }
};
